#ifndef PLAYFAB_PLAYFABERROR_H_
#define PLAYFAB_PLAYFABERROR_H_

#include <string>
#include <map>
#include <memory>
#include <functional>

namespace PlayFab
{
    enum PlayFabErrorCode
    {
        PlayFabErrorHostnameNotFound = 1,
        PlayFabErrorConnectionTimeout,
        PlayFabErrorConnectionRefused,
        PlayFabErrorSocketError,
        <% for(var i=0; i<errorList.length-1; i++) { var errorProps = errors[errorList[i]] %>PlayFabError<%- errorProps.name %> = <%- errorProps.id %>,
        <% } %>PlayFabError<% var errorProps = errors[errorList[errorList.length-1]] %><%- errorProps.name %> = <%- errorProps.id %>
    };

    struct PlayFabError
    {
        int HttpCode;
        std::string HttpStatus;
        int ErrorCode;
        std::string ErrorName;
        std::string ErrorMessage;
        std::multimap< std::string, std::string > ErrorDetails;

        inline std::string GenerateErrorReport() const
        {
            std::string output = "";
            output += ErrorMessage;

            for (auto it = ErrorDetails.begin(); it != ErrorDetails.end(); ++it)
            {
                if (output.length() > 0)
                    output += "\n";
                output += it->first + ": " + it->second;
            }
            return output;
        }
    };

    typedef std::function<void(const PlayFabError& error, void* userData)> ErrorCallback;
}
#endif
